
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>zookeeper03单机安装 · Zookeeper</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="<yangxin19970404@163.com>">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="zookeeper04新增节点.html" />
    
    
    <link rel="prev" href="zookeeper02数据模型.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="zookeeper01概述.html">
            
                <a href="zookeeper01概述.html">
            
                    
                    zookeeper01概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="zookeeper02数据模型.html">
            
                <a href="zookeeper02数据模型.html">
            
                    
                    zookeeper02数据模型
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="zookeeper03单机安装.html">
            
                <a href="zookeeper03单机安装.html">
            
                    
                    zookeeper03单机安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="zookeeper04新增节点.html">
            
                <a href="zookeeper04新增节点.html">
            
                    
                    zookeeper04新增节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="zookeeper05操作节点.html">
            
                <a href="zookeeper05操作节点.html">
            
                    
                    zookeeper05操作节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="zookeeper06监听器.html">
            
                <a href="zookeeper06监听器.html">
            
                    
                    zookeeper06监听器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="zookeeper07acl权限控制.html">
            
                <a href="zookeeper07acl权限控制.html">
            
                    
                    zookeeper07acl权限控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="zookeeper08javaApi连接zookeeper.html">
            
                <a href="zookeeper08javaApi连接zookeeper.html">
            
                    
                    zookeeper08javaApi连接zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="zookeeper09事件监听机制watcher.html">
            
                <a href="zookeeper09事件监听机制watcher.html">
            
                    
                    zookeeper09事件监听机制watcher
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >zookeeper03单机安装</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="zookeeper&#x5355;&#x673A;&#x5B89;&#x88C5;">zookeeper&#x5355;&#x673A;&#x5B89;&#x88C5;</h3>
<ol>
<li>&#x5728;centos&#x4E2D;&#x4F7F;&#x7528;root&#x7528;&#x6237;&#x521B;&#x5EFA;zookeeper&#x7528;&#x6237;</li>
</ol>
<pre><code class="lang-bash">[root@izijy66dzll7bdz /]<span class="hljs-comment"># useradd zookeeper</span>
[root@izijy66dzll7bdz /]<span class="hljs-comment"># passwd zookeeper</span>
&#x66F4;&#x6539;&#x7528;&#x6237; zookeeper &#x7684;&#x5BC6;&#x7801; &#x3002;
&#x65B0;&#x7684; &#x5BC6;&#x7801;&#xFF1A;
&#x65E0;&#x6548;&#x7684;&#x5BC6;&#x7801;&#xFF1A; &#x5BC6;&#x7801;&#x5305;&#x542B;&#x7528;&#x6237;&#x540D;&#x5728;&#x67D0;&#x4E9B;&#x5730;&#x65B9;
&#x91CD;&#x65B0;&#x8F93;&#x5165;&#x65B0;&#x7684; &#x5BC6;&#x7801;&#xFF1A;
passwd&#xFF1A;&#x6240;&#x6709;&#x7684;&#x8EAB;&#x4EFD;&#x9A8C;&#x8BC1;&#x4EE4;&#x724C;&#x5DF2;&#x7ECF;&#x6210;&#x529F;&#x66F4;&#x65B0;&#x3002;
[root@izijy66dzll7bdz /]<span class="hljs-comment">#</span>
</code></pre>
<ol>
<li>zookeeper&#x5E95;&#x5C42;&#x4F9D;&#x8D56;&#x4E8E;jdk,zookeeper&#x767B;&#x5F55;&#x4E4B;&#x540E;&#x5148;&#x5B89;&#x88C5;jdk,</li>
</ol>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x89E3;&#x538B;jdk</span>
[root@izijy66dzll7bdz <span class="hljs-built_in">local</span>]<span class="hljs-comment"># tar -zxvf jdk-8u181-linux-x64.tar.gz</span>
</code></pre>
<ol>
<li>&#x914D;&#x7F6E;jdk&#x73AF;&#x5883;&#x53D8;&#x91CF;</li>
</ol>
<pre><code class="lang-shell">
# vim /etc/profile  &#x8FDB;&#x5165;&#x73AF;&#x5883;&#x914D;&#x7F6E;&#x6587;&#x4EF6;

export JAVA_HOME=/usr/local/jdk1.8.0_181  #jdk&#x5B89;&#x88C5;&#x76EE;&#x5F55;

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH

export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin

export PATH=$PATH:${JAVA_PATH}
</code></pre>
<ol>
<li>&#x751F;&#x6548;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
</ol>
<pre><code class="lang-bash">[root@localhost <span class="hljs-built_in">local</span>]<span class="hljs-comment"># source /etc/profile</span>
</code></pre>
<ol>
<li>zookeeper&#x767B;&#x5F55;&#x4E4B;&#x540E;&#x5B89;&#x88C5;zookeeper</li>
</ol>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x89E3;&#x538B;</span>
[root@izijy66dzll7bdz <span class="hljs-built_in">local</span>]<span class="hljs-comment"># tar -xzvf apache-zookeeper-3.7.0.tar.gz</span>
</code></pre>
<ol>
<li>&#x4E3A;zookeeper&#x51C6;&#x5907;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
</ol>
<pre><code class="lang-shell">
# &#x5728;&#x6839;&#x76EE;&#x5F55;&#x65B0;&#x5EFA;&#x4E2A;&#x6587;&#x4EF6;&#x5939;
[root@izijy66dzll7bdz apache-zookeeper-3.7.0]# mkdir data
# &#x8FDB;&#x5165;conf&#x76EE;&#x5F55;
cd /usr/local/apache-zookeeper-3.7.0/conf
# &#x590D;&#x5236;&#x914D;&#x7F6E;&#x6587;&#x4EF6;
[root@izijy66dzll7bdz conf]# cp zoo_sample.cfg zoo.cfg
[root@izijy66dzll7bdz conf]# ls
configuration.xsl  log4j.properties  zoo.cfg  zoo_sample.cfg
# vim&#x4FEE;&#x6539;&#x6587;&#x4EF6;&#x4E2D;&#x7684;dataDir &#x6B64;&#x8DEF;&#x5F84;&#x7528;&#x4E8E;&#x5B58;&#x50A8;zookeeper&#x4E2D;&#x6570;&#x636E;&#x7684;&#x5185;&#x5B58;&#x5FEB;&#x7167;&#x53CA;&#x4E8B;&#x52A1;&#x65E5;&#x5FD7;&#x6587;&#x4EF6;
dataDir=/usr/local/apache-zookeeper-3.7.0/data
</code></pre>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210328170215.png" alt=""></p>
<ol>
<li>&#x542F;&#x52A8;zookeeper</li>
</ol>
<pre><code class="lang-bash">
<span class="hljs-comment"># &#x542F;&#x52A8;: zkServer.sh start</span>
<span class="hljs-comment"># &#x505C;&#x6B62;: zkServer.sh stop</span>
<span class="hljs-comment"># &#x67E5;&#x770B;&#x72B6;&#x6001;: zkServer.sh status</span>


<span class="hljs-comment"># &#x8FDB;&#x5165;bin&#x76EE;&#x5F55;&#x542F;&#x52A8;zookeeper</span>
[zookeeper@izijy66dzll7bdz bin]$ ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/<span class="hljs-built_in">local</span>/apache-zookeeper-3.7.0/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START
[zookeeper@izijy66dzll7bdz bin]$ 

<span class="hljs-comment"># &#x6CA1;&#x542F;&#x52A8;&#x6210;&#x529F;,&#x67E5;&#x770B;&#x4E00;&#x4E0B;&#x65E5;&#x5FD7;,</span>
[zookeeper@izijy66dzll7bdz bin]$ ./zkServer.sh start-foreground
ZooKeeper JMX enabled by default
Using config: /usr/<span class="hljs-built_in">local</span>/apache-zookeeper-3.7.0/bin/../conf/zoo.cfg
&#x9519;&#x8BEF;: &#x627E;&#x4E0D;&#x5230;&#x6216;&#x65E0;&#x6CD5;&#x52A0;&#x8F7D;&#x4E3B;&#x7C7B; org.apache.zookeeper.server.quorum.QuorumPeerMain
<span class="hljs-comment">#&#x4E8E;&#x662F;&#x6211;&#x5C31;&#x6362;&#x4E86;&#x4E00;&#x4E2A;&#x7248;&#x672C;</span>


<span class="hljs-comment"># &#x6362;&#x5B8C;&#x7248;&#x672C;&#x5C31;&#x6210;&#x4E86;</span>
[zookeeper@izijy66dzll7bdz bin]$ ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/<span class="hljs-built_in">local</span>/apache-zookeeper-3.6.2-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[zookeeper@izijy66dzll7bdz bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/<span class="hljs-built_in">local</span>/apache-zookeeper-3.6.2-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone

<span class="hljs-comment"># &#x8FDB;&#x5165;&#x5230;&#x5BA2;&#x6237;&#x7AEF;</span>
[zookeeper@izijy66dzll7bdz bin]$ ./zkCli.sh


WATCHER::

WatchedEvent state:SyncConnected <span class="hljs-built_in">type</span>:None path:null
[zk: localhost:2181(CONNECTED) 0] 

<span class="hljs-comment"># &#x5173;&#x95ED;</span>
[zookeeper@izijy66dzll7bdz bin]$ ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /usr/<span class="hljs-built_in">local</span>/apache-zookeeper-3.6.2-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[zookeeper@izijy66dzll7bdz bin]$
</code></pre>
<h2 id="&#x7ED9;&#x666E;&#x901A;&#x7528;&#x6237;&#x8D4B;&#x6743;&#x9650;">&#x7ED9;&#x666E;&#x901A;&#x7528;&#x6237;&#x8D4B;&#x6743;&#x9650;</h2>
<pre><code class="lang-shell"># &#x8D4B;&#x5199;,&#x6267;&#x884C;&#x6743;&#x9650;  -R &#x9012;&#x5F52;&#x8D4B;&#x6743;&#x9650;
[root@izijy66dzll7bdz local]# chmod o+x -R apache-zookeeper-3.6.2-bin
[root@izijy66dzll7bdz local]# chmod o+w -R apache-zookeeper-3.6.2-bin 
[root@izijy66dzll7bdz local]# chmod 777 -R apache-zookeeper-3.6.2-bin
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="zookeeper02数据模型.html" class="navigation navigation-prev " aria-label="Previous page: zookeeper02数据模型">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="zookeeper04新增节点.html" class="navigation navigation-next " aria-label="Next page: zookeeper04新增节点">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"zookeeper03单机安装","level":"1.4","depth":1,"next":{"title":"zookeeper04新增节点","level":"1.5","depth":1,"path":"zookeeper04新增节点.md","ref":"zookeeper04新增节点.md","articles":[]},"previous":{"title":"zookeeper02数据模型","level":"1.3","depth":1,"path":"zookeeper02数据模型.md","ref":"zookeeper02数据模型.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"<yangxin19970404@163.com>","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Zookeeper","language":"zh-hans","gitbook":"3.2.3","description":"Zookeeper > 分布式服务管理框架"},"file":{"path":"zookeeper03单机安装.md","mtime":"2021-04-17T07:00:09.658Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T08:10:28.423Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

